package com.work.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.annotations.Case;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpRequest;

/**
 * 
 * @author zhubingyi
 * @version 1.1
 * @description:声明日期的类
 *
 */
public class DateUtil {
	
	//获取一天的时段：早上 <7、上午、中午、下午、晚上
	@SuppressWarnings("deprecation")
	public static String getTimeHello(){
		Date date = new Date();
		int hours = date.getHours();
		int flag=((hours<7)==true?1:0)+((hours>=7&&hours<11)==true?2:0)+((hours>=11&&hours<13)==true?3:0)+((hours>=13&&hours<18)==true?4:0)+((hours>=18&&hours<24)==true?5:0);
		String nowTime=null;
		switch(flag){
	     	case 1:
	     		 nowTime="早上";
	     		 //System.out.println("早上");break;
	     	case 2:
	     		nowTime="上午";
	     		 //System.out.println("上午");break;
	     	case 3:
	     		nowTime="中午";
	     		 //System.out.println("中午");break;
	     	case 4:
	     		nowTime="下午";
	     		 System.out.println("下午");break;
	     	case 5:
	     		nowTime="晚上";
	     		System.out.println("晚上");break;
	     	default: 
	     		nowTime="您获取的时间有误，请重新获取"; 	 
		}
		
		return nowTime;
	}
    
    public static void main(String[] args) {
		getTimeHello();
    	//GregorianCalendar ca = new GregorianCalendar();
        //System.out.println(ca.get(GregorianCalendar.AM_PM));
	}
    
	
	
}
